import java.awt.Color;


public class EdgeDetection
{
   public static void main(String[] args)
   {
      final int THRESHOLD = 10;
      
      Picture original = new Picture("/Users/locphan/Documents/workspace/Lab10/butterfly1.jpg");
      Picture modified = new Picture("/Users/locphan/Documents/workspace/Lab10/butterfly1.jpg");
      
      int stop = modified.getWidth()-1;
      double contrast = 0;
      
      
      int height = modified.getHeight();
      
      for(int x = 0; x<stop;x++)
      {
         for(int y =0; y<height;y++)
         {
            contrast = modified.getPixel(x, y).getAverage() - modified.getPixel(x+1, y).getAverage();
            
            if(Math.abs(contrast)<THRESHOLD)
            {
               modified.getPixel(x, y).setColor(Color.white);
             
            }
            else
            {
               modified.getPixel(x, y).setColor(Color.black);
            }
         }
      }
      
      original.show();
      modified.show();
    }
}
